using System;
using System.Text;
using System.Text.RegularExpressions;


namespace SharePoint.ImportExport.Core
{
	/// <summary>
	/// This is a collection of helper functions
	/// </summary>
	public sealed class Miscallaneous
	{
		private Miscallaneous()
		{
		}
		/// <summary>
		/// Helper function for removing characters not allowed in SharePoint. 
		/// </summary>
		/// <param name="toBeFixed"></param>
		/// <returns>A string that SharePoint acceps</returns>
		public static string FixName(string toBeFixed)
		{
			string pattern=@"[\\\?=:\]\[/\*\>\<\|&\%#~\x22\']";
		
			Regex regEx = new Regex(pattern);

			return regEx.Replace(toBeFixed,"_");
		}

//
//	
//			if(-1 != str.IndexOfAny(escapeChars))
//			{
//
//				str = str.Replace("?","_");
//				str = str.Replace("=","_");
//				str = str.Replace(":","_");
//				str = str.Replace("/","_");
//				str = str.Replace("\\","_");
//				str = str.Replace("*","_");
//				str = str.Replace(">","_");
//				str = str.Replace("<","_");
//				str = str.Replace("|","_");
//				str = str.Replace("\"","_");
//
//				// The following are not valid in WSS
//
//				str = str.Replace("&"," And ");  
//				str = str.Replace("&"," And ");  
//				str = str.Replace("%"," PCT ");
//				str = str.Replace("#","_");
//				str = str.Replace("~","_");
//				str = str.Replace("[","_");
//				str = str.Replace("]","_");
//			}
//			str = str.Replace("..","_");  
//
//			return str;
//		}
	
	}
}
